package com.mao.builderpattern;

public class Computer {


    private Computer(){

    }

    private Computer(String cpu, String display, String keyboard) {
        this.cpu = cpu;
        this.display = display;
        this.keyboard = keyboard;
    }

    private String cpu;

    private String display;

    private String keyboard;

    public String getCpu() {
        return cpu;
    }

    public void setCpu(String cpu) {
        this.cpu = cpu;
    }

    public String getDisplay() {
        return display;
    }

    public void setDisplay(String display) {
        this.display = display;
    }

    public String getKeyboard() {
        return keyboard;
    }

    public void setKeyboard(String keyboard) {
        this.keyboard = keyboard;
    }


    public static class Builder{

        String cpu;
        String display;
        String keyboard;

        public Builder buildCpu(String cpu){
            System.out.println("build cpu:"+cpu);
            this.cpu=cpu;
            return this;
        }
        public Builder buildDisplay(String display){
            System.out.println("build display:"+display);
            this.display=display;
            return this;
        }
        public Builder buildKeyboard(String keyboard){
            System.out.println("build keyboard:"+keyboard);
            this.keyboard=keyboard;
            return this;
        }

        public Computer build(){
            return new Computer(cpu,display,keyboard);
        }


    }



    @Override
    public String toString() {
        return "Computer{" +
                "cpu='" + cpu + '\'' +
                ", display='" + display + '\'' +
                ", keyboard='" + keyboard + '\'' +
                '}';
    }
}
